<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <title>跳蚤市场</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" type="text/css" href="/Public/css/bootstrap.css" />
  <link rel="stylesheet" type="text/css" href="/Public/css/schoolshop.css" />
  <script type="text/javascript" src="/Public/js/jquery-1.11.2.js"></script>
  <script type="text/javascript" src="/Public/js/bootstrap.js"></script>
  <script type="text/javascript" src="/Public/Matrix/js/matrix.js"></script>
  <load href="/Public/js/jquery.masonry.min.js"></script>
</head>
<body>
 <nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container">
            <?php if(!empty($cateRow)): function showTree($data) { echo '<ul class="nav navbar-nav">'; echo '<li><a href="/Index/index">首页</a></li>'; foreach ($data as $key => $val) { echo ' <li class="dropdown">'; echo '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">'.$val['catename'].'<span class="caret"></span></a>'; if (!empty($val['childs'])) { echo '<ul class="dropdown-menu" role="menu">'; foreach ($val['childs'] as $key => $val) { echo '<li><a href="#">'.$val['catename'].'</a></li>'; } echo '</ul>'; } echo '</li>'; } echo '</ul>'; } showTree($cateRow); endif; ?>
            <!--            
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            -->
    <ul class="nav navbar-nav navbar-right">
            <li><a href="/Index/release"><button type="button" class="btn btn-success navbar-btn navbtn">发布宝贝</button></a></li>
            <li><a href="/Index/register"><button type="button" class="btn btn-success navbar-btn navbtn">注册</button></a></li>
            <li><a href="/Com/login"><button type="button" class="btn btn-success navbar-btn navbtn">登陆</button></a></li>
            <li><a href="/User/index"><button type="button" class="btn btn-success navbar-btn navbtn">个人中心</button></a></li>
    </ul>
  </div>
</nav>
<div id="container" class=" container waterfall">
<?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="babycontent">
		<a href="#">
		<img src="<?php echo ($vo["picurl"]); ?>" width="246px" height="200px" class="img-rounded">
		<h4 class="text-center"><?php echo ($vo["babyname"]); ?></h4>
		</a>
		<div class="contcont">
		<p class="text_cont lead">价格：<span style="color:red;">￥<?php echo ($vo["babymoney"]); ?></span></p>
		<button type="button" class="btn btn-default btn-center">查看详情>></button>
		</div>

		<div class="contfoot">
			<h5>发布日期：<?php echo (date('Y-m-d',$vo["day"])); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;By:<?php echo ($vo["clientname"]); ?></h5>
		</div>
	</div><?php endforeach; endif; else: echo "" ;endif; ?>
</div>
<div id="loading" class="loading-wrap">
	<span class="loading">加载中，请稍后...</span>
</div>
<script type="text/javascript">
$(function(){
    //执行瀑布流
    var $container = $('#container');
	  $container.masonry({
	    itemSelector : '.item',
	    isAnimated: true
	  });

	var loading = $("#loading").data("on", false);
	$(window).scroll(function(){
		if(loading.data("on")) return;
		if($(document).scrollTop() > 
			$(document).height()-$(window).height()-$('.footer').height()){
			//加载更多数据
			loading.data("on", true).fadeIn();
			$.get(
				"/Index/getMore", 
				{"last_id" : $("#container>div:last>input").val()},
				function(data){
					var html = "";
					if($.isArray(data)){
						for(i in data){
							html += "<div class=\"babycontent\"><img src="<?php echo ($vo["picurl"]); ?>" width=\"246px\" height=\"200px\" class=\"img-rounded\"></div>"
							html += "<input type=\"hidden\" name=\"id\" value=\""+data[i]['id']+"\"/></div>";
						}
						var $newElems = $(html).css({ opacity: 0 }).appendTo($container);
						$newElems.imagesLoaded(function(){
							$newElems.animate({ opacity: 1 });
							$container.masonry( 'appended', $newElems, true ); 
				        });
				        loading.data("on", false);
					}
					loading.fadeOut();
				},
				"json"
			);
		}
	});
});
</script>
</body>
</html>